import React from 'react'
import Luo from 'iscroll-luo';
import {useEffect,useState} from "react"
import {useDispatch,useSelector} from "react-redux"
import * as action from "../action"
function Push() {
   const [val,setVal] = useState("")
   const fn = (e)=>{
        console.log(e.target.value);
        setVal(e.target.value)
   }
   const store = useSelector((state)=>{
        return {
            ...state. tablereducer
        }
   })

   const dispatch = useDispatch()
   useEffect(()=>{
        dispatch(action.getlist())
   },[])
   const onDown = ()=>{
  
    dispatch(action.getlist("xiala"))
   }
   const onUp = ()=>{
    dispatch(action.getlist("shangla"))
   }
   const searfn = () =>{
       dispatch(action.searchFn(val))
   }
  return (
    <>
        <input type="text" value={val} onChange={fn}/> <button onClick={searfn}>搜索</button>
        <div style={{  height: '90vh' }}>
    <Luo
        id='id'
        onDown={() => onDown()}
        onUp={() => onUp()}
        options={
            {
                beyondHeight: 5,	
            } 
        }
        
    >
       {
           store.arr && store.arr.length?   store.arr.map((item,idnex)=>{
               return <dl key={idnex}>
                   <dt>
                       <img src={item.img} alt="" />
                   </dt>
                   <dd>{item.tit}</dd>
               </dl>
           }):"暂无数据"
       }					
    </Luo>
</div>
    
    
    </>
    
  )
}

export default Push